// 页面路径：store/index.js 
import Vue from 'vue'
import Vuex from 'vuex'

import createPersistedState from "vuex-persistedstate"
Vue.use(Vuex); //vue的插件机制

//Vuex.Store 构造器选项
const store = new Vuex.Store({
	plugins: [createPersistedState({
		storage: {
			getItem: key => uni.getStorageSync(key),
			setItem: (key, value) => uni.setStorageSync(key, value),
			removeItem: key => uni.removeStorageSync(key)
		}
	})],
	state: { //存放状态
		// poptab
		poplist: [],
		userinfo: {},
		categorylist: {},
		isyhtk: false
	},
	mutations: {
		setpoplist(state, list) {
			state.poplist = list
		},
		getuserinfo(state, data) {
			state.userinfo = data
			uni.setStorageSync('xxcstoken', data.token)
		},
		getcategorylist(state, list) {
			state.categorylist = list
		},
		setyhtk(status, data) {
			status.isyhtk = data

		}
	}
})
export default store